﻿<Window
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:n="http://nRoute/schemas/2010/xaml"
    xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity" 
    xmlns:ei="http://schemas.microsoft.com/expression/2010/interactions" 
	xmlns:ee="http://schemas.microsoft.com/expression/2010/effects" 
	xmlns:local_Behaviors="clr-namespace:nRoute.Samples.Netflix.Behaviors" 
	x:Name="window" x:Class="nRoute.Samples.Netflix.MainPage" 
    mc:Ignorable="d" SnapsToDevicePixels="True"
	WindowStartupLocation="CenterScreen"
    Width="1100" Height="580"
    d:DesignWidth="900" d:DesignHeight="480"
    TextOptions.TextFormattingMode="Display"
    TextOptions.TextRenderingMode="ClearType"
	PreviewMouseMove="ResetCursor"
    Title="{Binding Title, ElementName=ContentFrame, StringFormat=nRoute\'s Netflix : \{0\}, TargetNullValue=nRoute\'s Netflix}" 
	BorderBrush="#FF3F3F3F" WindowStyle="None" AllowsTransparency="True" Background="{x:Null}" Icon="Resources/nNetflix.ico">
    
    <i:Interaction.Behaviors>
    	<n:BridgeViewModelBehavior/>
    </i:Interaction.Behaviors>

    <i:Interaction.Triggers>
        <n:KeyTrigger Key="Backspace">
            <n:DirectionalNavigateAction HandlerName="browsingContainer"/>
        </n:KeyTrigger>
    </i:Interaction.Triggers>

    <Grid x:Name="LayoutRoot">
			
		<VisualStateManager.VisualStateGroups>
			<VisualStateGroup x:Name="WindowStateGroup">
				<VisualStateGroup.Transitions>
					<VisualTransition GeneratedDuration="0"/>
				</VisualStateGroup.Transitions>
				<VisualState x:Name="NormalState"/>
				<VisualState x:Name="MaximizedState">
					<Storyboard>
						<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="EdgeBorder">
							<DiscreteObjectKeyFrame KeyTime="0" Value="{x:Static Visibility.Collapsed}"/>
						</ObjectAnimationUsingKeyFrames>
						<ThicknessAnimationUsingKeyFrames Storyboard.TargetProperty="(FrameworkElement.Margin)" Storyboard.TargetName="ContentGrid">
							<EasingThicknessKeyFrame KeyTime="0" Value="0"/>
						</ThicknessAnimationUsingKeyFrames>
						<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="FrameGrid">
							<DiscreteObjectKeyFrame KeyTime="0" Value="{x:Static Visibility.Collapsed}"/>
						</ObjectAnimationUsingKeyFrames>
					</Storyboard>
				</VisualState>
			</VisualStateGroup>
		</VisualStateManager.VisualStateGroups>
		
		<VisualStateManager.CustomVisualStateManager>
			<ei:ExtendedVisualStateManager/>
		</VisualStateManager.CustomVisualStateManager>
		
		<i:Interaction.Triggers>
			<n:ValueMatchTrigger Source="{Binding WindowState, ElementName=window}" Value="Maximized">
				<ei:GoToStateAction StateName="MaximizedState" UseTransitions="False"/>
			</n:ValueMatchTrigger>
			<n:ValueMatchTrigger Negate="True" Source="{Binding WindowState, ElementName=window}" Value="Maximized">
				<ei:GoToStateAction StateName="NormalState" UseTransitions="False"/>
			</n:ValueMatchTrigger>
		</i:Interaction.Triggers>
		
		<Border x:Name="EdgeBorder" Margin="18" Background="White" IsHitTestVisible="False" IsEnabled="False" 
                d:IsLocked="True">
			<Border.Effect>
				<DropShadowEffect Opacity="0.695" BlurRadius="20" ShadowDepth="0"/>
			</Border.Effect>
		</Border>
		
	    <Grid x:Name="ContentGrid" Margin="18" Style="{StaticResource LayoutRootGridStyle}" Background="White">
	        <Rectangle Height="55" VerticalAlignment="Top" Fill="White" PreviewMouseDown="Header_Drag"/>
			<TextBlock x:Name="textBlock" FontSize="16" Margin="90,13,450,0" VerticalAlignment="Top" 
				Foreground="#FFD0D0D0" TextTrimming="CharacterEllipsis" IsHitTestVisible="False" Opacity="0">
				<i:Interaction.Behaviors>
					<local_Behaviors:NavigateBackInfoBehavior BrowsingContainer="{Binding ElementName=browsingContainer, Mode=OneWay}"/>
				</i:Interaction.Behaviors>
				<i:Interaction.Triggers>
					<i:EventTrigger EventName="MouseLeftButtonUp">
						<n:DirectionalNavigateAction HandlerName="browsingContainer"/>
					</i:EventTrigger>
				</i:Interaction.Triggers>
			</TextBlock>
			<Button VerticalAlignment="Top" HorizontalAlignment="Left" Margin="59,14,0,0" 
				Style="{DynamicResource ChromeButtonStyle}" SnapsToDevicePixels="True" >
				<i:Interaction.Behaviors>
					<n:BoolValueInteractivityBehavior NonInteractiveOpacity="0.5"
						Value="{Binding CanNavigateBack, ElementName=browsingContainer, Mode=OneWay}"/>
				</i:Interaction.Behaviors>
				<i:Interaction.Triggers>
					<i:EventTrigger EventName="Click">
						<n:DirectionalNavigateAction HandlerName="browsingContainer"/>
					</i:EventTrigger>
					<i:EventTrigger EventName="MouseEnter">
						<n:TargetedSetPropertyAction TargetObject="{Binding ElementName=textBlock}" 
							PropertyName="Opacity" Value="1"/>
					</i:EventTrigger>
					<i:EventTrigger EventName="MouseLeave">
						<n:TargetedSetPropertyAction TargetObject="{Binding ElementName=textBlock}" 
							PropertyName="Opacity" Value="0"/>
					</i:EventTrigger>
				</i:Interaction.Triggers>
				<Path Stretch="Fill" Stroke="#FF474747" Width="20" RenderTransformOrigin="0.5,0.5" Fill="#00FF0000"
					Height="20"	d:LayoutOverrides="HorizontalAlignment" StrokeThickness="1"
					Data="M137.5,70 C137.5,107.27922 107.27922,137.5 70,137.5 C32.720779,137.5 2.5,107.27922 2.5,70 C2.5,32.720779 32.720779,2.5 70,2.5 C107.27922,2.5 137.5,32.720779 137.5,70 z M33.166992,72.333008 L111.16699,72.333008 M70.833,32.333019 L109.846,71.346016 M112.49997,70.5 L74.969971,108.03" d:IsLocked="True">
					<i:Interaction.Behaviors>
						<n:BoolValueInteractivityBehavior NonInteractiveOpacity="0.5"
							Value="{Binding CanNavigateBack, ElementName=browsingContainer, Mode=OneWay}"/>
					</i:Interaction.Behaviors>
					<Path.RenderTransform>
						<TransformGroup>
							<ScaleTransform ScaleX="-1" />
							<SkewTransform AngleX="0"
								AngleY="0" />
							<RotateTransform Angle="0" />
							<TranslateTransform />
						</TransformGroup>
					</Path.RenderTransform>
				</Path>
			</Button>
			<TextBox x:Name="textBox" Height="25" Margin="500,11,73,0" VerticalAlignment="Top" 
				HorizontalAlignment="Right" Width="189" Padding="1,3,24,1" BorderBrush="#FFC7CACF">
                <i:Interaction.Triggers>
                    <ei:KeyTrigger Key="Return">
                        <local_Behaviors:SearchContainerAction SearchText="{Binding Text, ElementName=textBox}" 
							TargetObject="{Binding ElementName=ContentFrame}"/>
                    </ei:KeyTrigger>
                    <n:KeyTrigger Key="Backspace" SetIsHandled="True"/>
                </i:Interaction.Triggers>
            </TextBox>
        	<TextBlock 
        		FontSize="13.333" Margin="500,14.5,212,0" VerticalAlignment="Top" 
        		TextTrimming="CharacterEllipsis" Foreground="#FFD0D0D0" FontFamily="Segoe UI Semibold" Text="Search" HorizontalAlignment="Right" IsHitTestVisible="False">
        		<i:Interaction.Behaviors>
        			<local_Behaviors:TextBoxWatermarkBehavior TextBox="{Binding ElementName=textBox, Mode=OneWay}"/>
        		</i:Interaction.Behaviors>
        	</TextBlock>
        	<Path Data="M16.581301,11.680997 C16.581301,14.418091 14.344331,16.636944 11.584888,16.636944 8.8254444,16.636944 6.5884738,14.418091 6.5884738,11.680997 6.5884738,8.9439026 8.8254444,6.7250495 11.584888,6.7250495 14.344331,6.7250495 16.581301,8.9439026 16.581301,11.680997 z M14.716612,15.63386 L19.088474,20.22505" 
				HorizontalAlignment="Right" Margin="500,18.556,83.309,0" Stretch="Fill" Stroke="#FFD0D0D0" 
				UseLayoutRounding="False" Width="11.712" RenderTransformOrigin="0.484383698185273,0.508401108359125" 
				Fill="#00000000" d:LayoutOverrides="GridBox" Height="12.569" VerticalAlignment="Top">
        		<Path.RenderTransform>
        			<TransformGroup>
        				<ScaleTransform/>
        				<SkewTransform/>
        				<RotateTransform Angle="28.279"/>
        				<TranslateTransform X="2.8663341955609738" Y="-1.78868809092684"/>
        			</TransformGroup>
        		</Path.RenderTransform>
        	</Path>
        	<Button HorizontalAlignment="Right" Margin="500,6,45,0" VerticalAlignment="Top" 
				Style="{StaticResource ChromeButtonStyle}" Click="MinimizeButton_Click">
				<TextBlock TextWrapping="Wrap" Text="0" FontFamily="Webdings" Foreground="#FF919191" FontSize="13.333"/>
			</Button>
        	<Button HorizontalAlignment="Right" Margin="500,6,26,0" VerticalAlignment="Top" 
				Style="{StaticResource ChromeButtonStyle}" Click="RestoreButton_Click">
				<TextBlock TextWrapping="Wrap" Text="1" FontFamily="Webdings" Foreground="#FF919191" FontSize="13.333"/>
			</Button>
        	<Button HorizontalAlignment="Right" Margin="500,6,8,0" VerticalAlignment="Top" 
				Style="{StaticResource ChromeButtonStyle}" Click="CloseButton_Click">
				<TextBlock TextWrapping="Wrap" Text="r" FontFamily="Webdings" Foreground="#FF919191" FontSize="13.333" />
			</Button>
        	<Grid x:Name="NavigationGrid" Style="{StaticResource NavigationGridStyle}">

        		<Border x:Name="LinksBorder" Style="{StaticResource LinksBorderStyle}">
        			<ItemsControl ItemsSource="{Binding SiteMapNodes}" IsTabStop="False" 
        				ItemsPanel="{StaticResource HeaderLinksItemsTemplate}"
        				ItemTemplate="{StaticResource HeaderLinkItemTemplate}">	            		
        				<i:Interaction.Behaviors>
        					<local_Behaviors:SetActiveLinkBehavior NavigationContainer="{Binding ElementName=ContentFrame, Mode=OneWay}"/>
        				</i:Interaction.Behaviors>
        			</ItemsControl>
        		</Border>

        		<Border x:Name="BrandingBorder" Style="{StaticResource BrandingBorderStyle}">
        			<StackPanel x:Name="BrandingStackPanel" Style="{StaticResource BrandingStackPanelStyle}">

        				<ContentControl Style="{StaticResource LogoIcon}" Margin="600,0,260,0" IsHitTestVisible="False"/>
        				<TextBlock x:Name="ApplicationNameTextBlock" Style="{StaticResource ApplicationNameStyle}" 
        					Text="nRoute's Netflix" TextOptions.TextFormattingMode="Display" TextOptions.TextRenderingMode="ClearType" 
							TextOptions.TextHintingMode="Auto" FontSize="26.667" Margin="0,-14,0,0" FontFamily="Segoe UI Light" 
							IsHitTestVisible="False" FontWeight="Bold"/>

        			</StackPanel>
        		</Border>

        	</Grid>			
	        <Border x:Name="ContentBorder" Style="{StaticResource ContentBorderStyle}" Background="{x:Null}" 
				Margin="60,155,0,0" BorderThickness="0">
	        	<Grid>
	        		<Grid.RowDefinitions>
	        			<RowDefinition Height="32"/>
	        			<RowDefinition Height="*"/>
	        		</Grid.RowDefinitions>
	        		<Grid.ColumnDefinitions>
	        			<ColumnDefinition Width="320"/>
	        			<ColumnDefinition/>
	        		</Grid.ColumnDefinitions>
					
					<TextBlock Text="{Binding Title, ElementName=ContentFrame}" 
						FontSize="13.333" Margin="20,0,8,0" VerticalAlignment="Center" 
						TextTrimming="CharacterEllipsis" FontWeight="Bold"/>
											
					<TextBlock Text="{Binding Title, ElementName=browsingContainer}" 
						FontSize="13.333" Margin="15,0,8,0" VerticalAlignment="Center" 
						TextTrimming="CharacterEllipsis" Grid.Column="1" FontWeight="Bold"/>
					
		            <n:StatefulContainer x:Name="ContentFrame" Url="Content/Netflix/Genres/" 
						Style="{StaticResource ContentFrameStyle}" Grid.Row="1" >
		                <i:Interaction.Behaviors>
		                    <n:NavigationHandlerBehavior HandlerName="TopicContainer" IsDefaultHandler="True"/>
		                </i:Interaction.Behaviors>
		            </n:StatefulContainer>
					<n:BrowsingContainer x:Name="browsingContainer" Grid.Column="1" Grid.Row="1">
						<i:Interaction.Behaviors>
							<n:NavigationHandlerBehavior HandlerName="ContentContainer"/>
						</i:Interaction.Behaviors>
					</n:BrowsingContainer>
				</Grid>
	        </Border>
			
			<Border Background="#BFFFFFFF" Visibility="Collapsed" d:IsHidden="True" d:IsLocked="True">
				<i:Interaction.Behaviors>
					<n:BoolValueVisibilityBehavior Value="{Binding IsOpen, ElementName=popup}"/>
				</i:Interaction.Behaviors>
				<i:Interaction.Triggers>
					<i:EventTrigger EventName="MouseLeftButtonDown">
						<n:TargetedSetPropertyAction TargetObject="{Binding ElementName=popup}" PropertyName="IsOpen" 
							Value="False"/>
					</i:EventTrigger>
				</i:Interaction.Triggers>
			</Border>
			<Popup x:Name="popup" IsOpen="False" Margin="30" PopupAnimation="Fade" AllowsTransparency="True" Placement="MousePoint" HorizontalAlignment="Center" VerticalAlignment="Center" d:IsHidden="True" d:IsLocked="True">
				<i:Interaction.Behaviors>
					<local_Behaviors:PopupNavigationAdapterBehavior/>
					<n:NavigationHandlerBehavior HandlerName="PopupContainer"/>					
				</i:Interaction.Behaviors>	
			</Popup>

	    </Grid>
		
		<Grid Margin="18" x:Name="FrameGrid" d:IsLocked="True" >
			<Rectangle Stroke="{x:Null}" VerticalAlignment="Top" Height="7" x:Name="top" PreviewMouseDown="Resize" MouseMove="DisplayResizeCursor" Margin="8,0,8,0" Fill="#00000000"/>
			<Rectangle Stroke="{x:Null}" x:Name="bottom" Height="7" VerticalAlignment="Bottom" PreviewMouseDown="Resize" MouseMove="DisplayResizeCursor" Margin="8,0,8,0" Fill="#00000000"/>
			<Rectangle Stroke="{x:Null}" HorizontalAlignment="Left" Margin="0,7,0,7" Width="8" x:Name="left" PreviewMouseDown="Resize" MouseMove="DisplayResizeCursor" Fill="#00000000"/>
			<Rectangle Stroke="{x:Null}" Margin="0,7,0,7" Width="8" HorizontalAlignment="Right" x:Name="right" PreviewMouseDown="Resize" MouseMove="DisplayResizeCursor" Fill="#00000000"/>
			<Rectangle Stroke="{x:Null}" HorizontalAlignment="Left" VerticalAlignment="Bottom" Width="8" Height="7" x:Name="bottomLeft" PreviewMouseDown="Resize" MouseMove="DisplayResizeCursor" Fill="#00000000"/>
			<Rectangle Stroke="{x:Null}" VerticalAlignment="Bottom" Height="7" Width="8" HorizontalAlignment="Right" x:Name="bottomRight" PreviewMouseDown="Resize" MouseMove="DisplayResizeCursor" Fill="#00000000"/>
			<Rectangle Stroke="{x:Null}" HorizontalAlignment="Right" Width="8" Height="7" VerticalAlignment="Top" x:Name="topRight" PreviewMouseDown="Resize" MouseMove="DisplayResizeCursor" Fill="#00000000"/>
			<Rectangle Stroke="{x:Null}" HorizontalAlignment="Left" Width="8" VerticalAlignment="Top" Height="7" x:Name="topLeft" PreviewMouseLeftButtonDown="Resize"  MouseMove="DisplayResizeCursor" Fill="#00000000"/>
			<Path Data="M9.5390625,2.4619789 L9.5390625,11.133854 L0.8671875,11.133854 z" HorizontalAlignment="Right" Height="8.672" Margin="0,0,1.014,0.779" RenderTransformOrigin="0.5,0.5" Stretch="Fill" VerticalAlignment="Bottom" Width="8.672" d:LayoutOverrides="HorizontalAlignment, VerticalAlignment" StrokeDashArray="0.5 1" StrokeDashOffset="2" Fill="#FF119EDA" IsHitTestVisible="False" IsEnabled="False" StrokeThickness="0">
				<Path.RenderTransform>
					<TransformGroup>
						<ScaleTransform/>
						<SkewTransform/>
						<RotateTransform/>
						<TranslateTransform/>
					</TransformGroup>
				</Path.RenderTransform>
			</Path>
		</Grid>
		
	</Grid>
</Window>